If it was working before, try uninstalling the app(s) you put on it most recently. They might be the problem. After that, the first thing to try is probably a factory reset.
Edit: OK, so basically your ROM is totally screwed up. I would just replace it.
Some official firmware is linked in this XDA post. Download whichever you prefer, then use Odin as described below.
Download Odin for Windows (search for "Heimdall" if you are on Linux). Then do the following:
- Put your phone into Download mode
- Remove the battery
- Hold the VolumeDown, Camera, and End Call buttons:
- Reinsert the battery.
- After a few seconds a yellow triangle with an android in it should appear, you can let go of the keys since this is download mode.
- Start up Odin.
- Attach the phone to USB so that Odin recognizes it.
- Load the .tar file you downloaded (the ROM) into the PDA field of Odin. (If you got a .rar or .zip instead of a .tar, you need to extract the .tar inside the archive. A .tar.md5 file is fine.)
- Optional: Load the 512 .pit file into the PIT field of Odin and check "Re-partition". You should only do this if you screwed up the partitions or perhaps if flashing without this doesn't work. Make sure you have the appropriate .pit file for your device variant.
- Hit Start. Odin will tell you when it's done; if it fails, reboot your phone and try again. (This happens occasionally).
Note that you do this at your own risk; Odin is very powerful and misusing it can damage your phone. I've used it dozens of times myself safely.