The actual phrase was taken from the New Testament, specifically the phrase "for the letter killeth, but the spirit giveth life" (2 Corinthians 3:6). In this context, St. Paul was talking about the difference between legalism, which involves interpreting laws in an extremely literal fashion (something he associated with Judaism, especially with the Pharisees), and the spirit of charity, which attempted to look beyond a narrowly literal interpretation of the law to a more spiritual one (something Paul associated with Jesus). In religion, this often is seen as the difference between a religion grounded in charity or love and one focused on ritual.
In legal theory, this has been applied to following the spirit versus the letter of legal codes and constitutions, especially when those codes are being applied many centuries after they were written. For example, the Second Amendment to the US Constitution enshrines the right to bear arms, but it was written in 1791, a period in which guns could only shoot one bullet at a time and then required reloading. Thus people question whether the spirit of the amendment is focused on the ability to bear single-shot weapons (which can do only limited damage) or whether it includes assault rifles or nuclear weapons, things not invented in 1791.