This command can be used to change the essential status of an NPC (a specified base ID, not your target or a reference ID). An essential NPC is (by default) an NPC that is 'essential' to the game - e.g. an NPC necessary for a quest. Essential NPCs are 'immortal', they cannot be killed (as they're required for the game). An example of a non-essential NPC is a Whiterun Gaurd, there are many of them and no single Whiterun Guard is 'essential' to complete the game.
setessential [base id] [0 / 1]
|Base ID||The base ID of the NPC you wish to change the essential status of. This is NOT a reference ID - see NPC base IDs.|
|0 / 1||Specify (without quotes) '0' here to set the specified NPC as non-essential. Specify (without quotes) '1' here to set the specified NPC as essential.|
setessential 000A2C8E 0
Lydia's NPC base ID is 000A2C8E. This command would make Lydia non-essential (meaning Lydia can die and not respawn).
setessential 0005CF36 1
The NPC base ID of Aicantar's Spider is 0005CF36. The above console command would make Aicantar's Spider essential.