Bastard is a very pejorative term and is not used except as a swearword. Strictly speaking it does mean illegitimate but is never used in that context.

Bastard nowadays means an unpleasant and mean person - always a male. The female equivalent is bitch.