Locking the doors just stops sims getting into rooms, the only real reason for it is if you want certain rooms to be inaccessible to other sims. For example if you had an en suite bedroom, you could lock the bathroom door so only the sims in that bedroom can use it and other sims won't just walk through to use it. Or if you had a retail store you could lock the door to the break room and only allow staff in. Or if you have a dungeon in the basement, locking doors is also very useful then.