When I repair wooden boats I loosen nails by heating them with a very large electric soldering iron with a custom flat tip. While it is hot I drive the nail in a bit further with hammer and punch. Then I pull it.
However very old nails (mid 19th century and older) tend to be forged from wrought...