Quick Answer
If Earth's gravitational attraction vanished for exactly five seconds and then returned, objects would become effectively weightless and begin moving along inertial paths. Earth would not instantly leave the Sun's orbit because the Sun's gravity and Earth's orbital velocity are part of the larger system, but if all gravity everywhere vanished, orbital motions would temporarily become straight-line inertial motion. The return of gravity could create violent impacts and structural stresses depending on the object's height and surroundings.
Gravity is continuously acting on people, oceans, buildings, aircraft, the atmosphere and the Earth itself. Remove it for five seconds and the immediate experience would resemble a brief period of free fall — but the details depend on whether only Earth's gravity disappears or every gravitational interaction in the universe does.
People would become weightless
A person standing on the ground would no longer be held to the surface by gravity. The ground would also stop providing the normal force associated with weight, so both the person and nearby objects would begin following inertial trajectories. Buildings and other structures would not instantly explode, but their loads and stresses would change.
The atmosphere would move too
Air is already moving relative to the surface. Without gravity, the atmosphere would no longer be vertically stratified by hydrostatic pressure in the normal way. During only five seconds, it would not have time to escape Earth entirely, but pressure distributions would begin changing and local air would become effectively weightless.
The oceans
Ocean water would lose the gravitational force that keeps it pressed against Earth's surface. Five seconds is short compared with the timescale needed for oceans to travel enormous distances, so the main effect would be temporary reduction of the normal gravitational restoring force rather than instant oceans flying into space.
Would Earth leave the Sun?
If all gravity vanished, Earth would no longer curve around the Sun during those five seconds. It would travel approximately along its instantaneous inertial direction. The distance gained relative to its normal orbit would be small over five seconds, but the exact trajectory after gravity returned would depend on the complete gravitational system.
SpeculativeThe phrase 'gravity disappears' is ambiguous. General relativity does not provide a simple switch that turns gravity off everywhere. This article treats it as a thought experiment in which gravitational acceleration is temporarily removed while ordinary matter and its velocities remain otherwise unchanged.
Then gravity returns
The return could be the most disruptive moment. Objects that had moved upward or sideways relative to the surface would suddenly accelerate downward again. Anything that had lost contact with the ground could collide with it, while fluids and loose objects would redistribute abruptly.
Temporary free fall
People
Slight inertial deviation
Earth's orbit
Potentially violent impacts
Return
The bottom line
Five seconds is too short for Earth to fly apart, but long enough to remove the force that normally keeps every loose object pressed to the surface. The biggest danger would come from the chaotic motion of people, fluids and objects — especially when gravity switched back on.