Before there was a park and a palace, there was a hospital. Dating as far back as 1267, St. James's Hospital specialized in treating female lepers. The patients worked on the marshy land around the hospital as a part of their treatment, primarily raising hogs for the hospital to sell - not often a hospital is funded by pork. King Henry VIII acquired the land in 1532 to use as a hunting ground, making St. James's Park the oldest of London's Royal Parks.
While Henry VIII used the park to hunt, Queen Elizabeth hosted lavish parties in the park. King James invested in the park, adding gardens and a menagerie of exotic animals. As the English Civil War came to a close, King Charles made his final procession from St. James to Whitehall Palace, where his execution awaited him.
Charles II was the last monarch to take care of St. James's Park for some time. When he died, the park gained a reputation for criminal activity and prostitution. John Wilmot, the libertine Earl of Rochester, wrote a poem called A Ramble in St. James's Park that describes the unsavory happenings in the park in graphic detail. I've read it. Definitely NSFW. And it's rare you can say that about poetry.