Why does it hurt when I pee?

Mostly it is due to urethral or bladder inflammation typically from infection called urinary tract infections.
Drink plenty of water and urinate often is the best way to deal with UTI.