This isn't entirely unprecedented, but it's definitely not common.
TLDR:
No one really knows what could happen, but it wouldn't be the first time it's been attempted and not the first time someone won an office from prison. However, it could be the first (yet unlikely) time it is successful for POTUS. And lawyers from all over the US could be involved whatever the results.
Long form answer:
Joel Caston won at a city level, rather than Federal, and this is the first time a convict won, in 2021.
Joel Caston, 44, won the race for advisory neighborhood commissioner of district 7F07 in southeast D.C., where he'll oversee the Harriet Tubman Women's Shelter, new luxury apartments and D.C. Jail — where he is incarcerated.
...
Caston has been incarcerated since he was 18 after committing a felony offense, Julie Johnson, the founder of Neighbors for Justice told NBC News.
https://www.nbcnews.com/news/us-news/washington-d-c-inmate-becomes-first-incarcerated-person-city-win-n1271033
Trump wouldn't even be the first person to run for POTUS from prison. in 1920 Eugene V. Debs got around 3% of the popular votes, but lost his bid.
There are no legal obstacles to running for president as a convicted felon or even from behind bars. And if Trump finds himself in that predicament, he’ll be following in the footsteps of another rabble-rousing populist and frequent presidential candidate: the avowed socialist Eugene V. Debs, who received nearly a million votes while in prison a century ago.
Debs is far from the only person who has sought the highest office in the land while in prison, but he was the most successful. In 1920, he became the Socialist Party nominee while serving a 10-year federal sentence for urging people to resist the World War I draft.
https://www.politico.com/news/2023/04/06/trump-running-for-president-prison-00090931
The US Constitution puts few limitations on who can be POTUS or other public offices, presumably because the Founding Fathers didn't know what the future would hold, and they probably assumed no one would vote for someone who was incarcerated.
Candidates for president must:
- Be a natural-born citizen of the United States
- Be at least 35 years old
- Have been a resident of the United States for 14 years
https://www.usa.gov/requirements-for-presidential-candidates
In fact, the only disqualifications for POTUS are in the 14th Amendment, other than term limits and specific rules for removal from office.
"No person shall be a Senator or Representative in Congress, or elector of President and Vice-President, or hold any office, civil or military, under the United States, or under any state, who, having previously taken an oath, as a member of Congress, or as an officer of the United States, or as a member of any State legislature, or as an executive or judicial officer of any State, to support the Constitution of the United States, shall have engaged in insurrection or rebellion against the same, or given aid or comfort to the enemies thereof But Congress may by a vote of two-thirds of each House, remove such disability."
https://constitution.findlaw.com/amendment14/annotation15.html
The fact that someone was previously convicted can't be used to prevent that person from public office, with the exceptions of such the above listed insurrection or rebellion. If Trump were convicted of these or related crimes, such as seditious conspiracy, then he wouldn't be allowed to take office. It's unclear if he would be allowed to run to begin with, continue any existing campaign, or be allowed on ballots, but it would normally be assumed that if he wasn't allowed to take office, he would drop out of the race.
Unfortunately, in the case of Donald Trump, his disqualification to take office might be what triggers more conspiracy theories as well as more Jan 6th style riots and another attempted insurrection.
Also, voting regulations are handled at the state level, so him being allowed on ballots may be subject to what political party is in the majority in each individual state as well as what laws are officially on the books. Some states may even try to rush exceptions into law because of the situation (for and against a convicted Trump being on the ballot).
JamesK makes a case for Trump trying to lead from his cell, yet not being able to due to limitations of travel (or complete lack thereof) as well as visitors in the form of foreign dignitaries. There's also the much bigger problem of POTUS needing a security clearance to handle classified documents, as well as some classified documents being able to only be viewed inside a sensitive compartmented information facility (SCIF). (Part of Donald Trump's current legal problems with classified documents are that he removed some of them from a SCIF.)
For a moment, let's assume he wins and is allowed to take office:
I find it extremely difficult to believe that the FBI would give an inmate any kind of security clearance, especially one convicted of mishandling classified documents. Trump's administration was previously a problem for security clearances, with many of his administration originally denies a security clearance, but then the denial was reversed. I can see people trying to push the FBI to grant an incarcerated Trump a security clearance, but I also see a hard stance by the FBI to refuse doing so, up to and including multiple people retiring rather than giving him clearance.
Tricia Newbold, a longtime White House security adviser, told the House Oversight and Reform Committee that she and her colleagues issued “dozens” of denials for security clearance applications that were later approved despite their concerns about blackmail, foreign influence or other red flags, according to panel documents released Monday.
https://www.washingtonpost.com/powerpost/white-house-whistleblower-says-security-clearance-denials-were-reversed-during-trump-administration/2019/04/01/9f28334e-542c-11e9-814f-e2f46684196e_story.html
With Trump being in prison, he would be subject to all kinds of blackmail, threats of violence, criminal influence, and far more that I personally think would automatically and immediately disqualify him for a security clearance. The only way he could even attempt to do the job of POTUS is if he had his own penal wing, and that's just... wrong on so many levels. I think that's a precedent even a large amount of Republicans wouldn't want set.
A convicted Trump winning office also sets up the possibility of him pardoning himself, which is another precedent that pretty much anyone in Congress or any lawyer or judge in the country would likely want to avoid. This would completely erode any idea of laws being fair or just, and erode the idea that democracy existed in this country. (If we follow this slippery slope, it could also be a set up for Trump pronouncing himself some variety of dictator, but that's more based on the Jan 6th insurrection than "simply" any self-pardoning.)
Foreign relations would most likely cease to be favorable in any way, and that's with any POTUS being in prison.
In reality, there's a lot of supposition and general uncertainty of what could or will happen as this unfolds. About the only thing we can say for sure is that there's probably going to be a lot of lawsuits flying around regardless what happens.