Rhino 5 includes a tiny Python script editor and debugger (_EditPythonScript). In case the features of this mini integrated development environment (IDE) are considered to be insufficient an external IDE can be used.
A rather common way is to use Eclips/PyDev as a Rhino.Python editor. A brief tutorial how to set up PyDev is published by Steve Bear:
http://python.rhino3d.com/entries/12-Configuring-Pydev-for-Rhino.Python
PyDev can not only be used to edit a script, but also to debug a running Rhino.Python script. Since the script is interpreted by the IronPython interpreter included in Rhino the standard PyDev debugger can not be used. But PyDev includes a powerful remote debugger that can be utilized to debug a script executed by Rhino's IronPython. Remote debugging is achieved a debugging client run by the Rhino script that connects to a PyDev debugging server.
Here's how to start a remote debugging session
It is assumed that Eclips/PyDev are installed properly and configured to find the Rhino.Python libraries.
The script will be executed until pydevd.settrace is reached. Execution will stop now and control is handed over to the PyDev remote debugger. PyDev shows the current line in your source code and you can uses the debugger to inspect variables, set breakpoints, conditional breakpoints, step into function calls and so on.
It's a good idea to have Rhino running on a second screen as the rhino Window is not redrawn properly when switching between the PyDev and Rhino while debugging.
I tested this using Rhino 5 SR4 x64, Eclipse Kepler and Pydev 2.1. More information on the remote debugger and can PyDev debugging in general can be found here and here.
Remote Debugging Rhino.Python Scripts using Visual Studio
It should also be possible to use Microsoft Visual Studio, PTVS (Python Tools for Visual Studio) and the included ptvsd remote debugging client. If I find the time I'll test his soon and add the information here.
More information on pydevd and ghPython
Ángel Linares García wrote a more detailed tutorial focused on ghPython. You can find it here: ghPython and Eclipse workflow to edit and debug code.